package com.java.simple.study.jvm.memstruct.stack;

import java.util.Date;

/**
 * @author zhoujl
 * @date 2022/5/23 20:26
 * @desc
 */
public class LocalVariablesTest {
    private int count = 0;

    public static void main(String[] args) {
        LocalVariablesTest test = new LocalVariablesTest();
        int num = 10;
        test.test1();

    }

    public static void testStatic() {
        LocalVariablesTest localVariablesTest = new LocalVariablesTest();
        Date date = new Date();
        int count = 10;
        System.out.println(count);
        // 编译无法通过 因为this变量不在静态方法局部变量表中
        //System.out.println(this.count);
    }

    // 无参构造器 关于slot的使用理解
    public LocalVariablesTest() {
        // 成员方法局部变量表第一个就是this
        this.count = 1;
    }

    public void test1() {
        Date date = new Date();
        String name1 = "atguigu.com";
        test2(date, name1);
        System.out.println(date + name1);
    }

    public String test2(Date dataP, String name2) {
        dataP = null;
        name2 = "zhoujl";
        // 64字节 占用2个slot
        double weight = 130.5;
        char gender = '男';
        return dataP + name2;
    }

    public void test3() {
        this.count++;
    }

    public void test4() {
        int a = 0;
        {
            int b = 0;
            b = a + 1;
        }
        // 变量c使用之前 已经销毁的变量b占据的slot的位置
        int c = a + 1;
    }

}
